<script type="text/javascript" src="/themes/plugins/jquery/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="/themes/plugins/bootstrap/js/bootstrap.js"></script>


<script>
    function pwd_submit() {
        var password = $('input[name="password"]').val();
        var pwd = $('input[name="pwd"]').val();
        var pwd2 = $('input[name="pwd2"]').val();
        if (password.length == 0) {
            alert("请输入原密码");
            return;
        }
        if (pwd.length == 0) {
            alert("请输入新密码");
            return;
        }
        if (pwd2.length == 0) {
            alert("请输入确认密码");
            return;
        }
        if (pwd != pwd2) {
            alert("两次密码不一样");
            return;
        }
        $.getJSON("/member/modifyPwd", {password: password, pwd: pwd, pwd2: pwd2}, function (result) {
            if (result.code == 200) {
                alert("修改成功");
                location.href = "/join"
            } else {
                alert(result.message);
            }
        })
    }

</script>

<script>
    function collect(foodId, obj) {
    <#if sessionUser??>
        $.getJSON("/collection/collect", {foodId: foodId}, function (result) {
            if (result.code == 200) {
                if (result.message == 1) {
                    $(obj).find("i").removeClass("icon-star-empty");
                    $(obj).find("i").addClass("icon-star");
                } else {
                    $(obj).find("i").removeClass("icon-star");
                    $(obj).find("i").addClass("icon-star-empty");
                }
            } else {
                alert(result.message);
            }
        })
    <#else>
        alert("请先登录");
    </#if>
    }

    function saveItem(id, num) {
        if(num <=0 ){
            alert("至少点一份");
            return ;
        }
    <#if sessionUser??>
    $.getJSON("/order/saveItem",{footId:id,num:num},function(result){
        if (result.code == 200) {
            alert("点餐成功,请去餐车结账或者继续点餐");
        } else {
            alert(result.message);
        }
    })
    <#else>
        alert("请先登录");
    </#if>
    }
</script>
